package com.grsu.TransportSystem.validators;

import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.grsu.TransportSystem.domain.Proposal;

@Component("tripValidator")
public class TripValidator implements Validator {

	@Override
	public boolean supports(Class<?> clazz) {
		return Proposal.class.equals(clazz);
	}

	@Override
	public void validate(Object obj, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "name.required","bad name");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "from", "name.required","bad ");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "to", "name.required","bad ");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "cost", "name.required","bad ");
	}

}
